package hud;

import javafx.geometry.Insets;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;

public class SshTab {
    private static SshTab instance;
    private SshTab() {

    }

    public static SshTab Instance() {
        if (instance == null) {
            instance = new SshTab();
        }
        return instance;
    }

    public Tab Construct() {
        Tab tab = new Tab("SSH");
        tab.setClosable(false);

        VBox vBox = new VBox();
        vBox.setPadding(new Insets(5, 5, 5, 5));

        // 1. Checkbox
        CheckBox checkBox = new CheckBox("Use SSH tunnel");
        vBox.getChildren().add(checkBox);

        // 2. GridPane
        GridPane gridPane = new GridPane();
        gridPane.setVgap(8);
        gridPane.setHgap(4);
        gridPane.setPadding(new Insets(10, 10, 10, 10));

        // 2.1 1st row
        gridPane.add(new Label("SSH Address:"), 0, 0);
        TextField textField = new TextField("");
        gridPane.add(textField, 1, 0);

        // 2.2 2nd row
        gridPane.add(new Label("SSH User Name:"), 0, 1);
        textField = new TextField("");
        gridPane.add(textField, 1, 1);

        // 2.3 3rd row
        gridPane.add(new Label("SSH Auth Method:"), 0, 2);
        textField = new TextField("");
        gridPane.add(textField, 1, 2);

        // 2.4 4th row
        gridPane.add(new Label("Private key:"), 0, 3);
        textField = new TextField("");
        gridPane.add(textField, 1, 3);

        // 2.5 5th row
        gridPane.add(new Label("Passphrase:"), 0, 4);
        final ComboBox typeComboBox = new ComboBox();
        typeComboBox.getItems().addAll(
                "SCRAM-SHA-1",
                "SCRAM-SHA-256",
                "MONGODB-CR"
        );
        typeComboBox.getSelectionModel().select(0);
        gridPane.add(typeComboBox, 1, 4);

        // 2.6 6th row
        gridPane.add(new Label(""), 0, 6);
        CheckBox checkBox1 = new CheckBox("Ask for passphrase each time");
        gridPane.add(checkBox1, 1, 6);

        vBox.getChildren().add(gridPane);

        tab.setContent(vBox);

        return tab;
    }
}
